/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.knezevic.realestate.beans;

import com.knezevic.realestate.Advert;
import com.knezevic.realestate.service.Adverts;
import java.io.Serializable;
import java.util.Collection;
import java.util.HashMap;

/**
 *
 * @author Nemanja
 */
public class AdvertsServiceBean implements Adverts{

    private HashMap<Long, Advert> adverts;

    public AdvertsServiceBean(HashMap<Long, Advert> adverts) {
        super();
        this.adverts = adverts;
    }


    public AdvertsServiceBean() {
        this(new HashMap<Long, Advert>());
    }

    public Advert save(Advert advert) {
//        adverts.put(advert.getID(), advert);
//        return adverts.get(advert.getID());
        return advert;
    }

    public void update(Advert advert) {
//        adverts.remove(advert.getID());
//        adverts.put(advert.getID(), advert);
    }

    public void deleteAdvert(Advert advert) {
//        adverts.remove(advert.getID());
    }

    public Collection<Advert> retrieve() {
        return adverts.values();
    }

    public Advert retrieve(Serializable id) {
        return adverts.get(id);
    }

}
